<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .sliderbar {
            position: fixed;
            right: 0;
            bottom: 100px;
            width: 40px;
            height: 40px;
            text-align: center;
            line-height: 40px;
            cursor: pointer;
            color: #fff;
        }
        
        .con {
            position: absolute;
            left: 0;
            top: 0;
            width: 200px;
            height: 40px;
            background-color: purple;
            z-index: -1;
        }
    </style>
    <script src="13-animate.js"></script>
</head>
<body>
    <div class="sliderbar">
        <span>←</span>
        <div class="con">问题反馈</div>
    </div>
    <script>
        // 1. 获取元素
        var sliderbar = document.querySelector('.sliderbar')  // 父盒子
        var con = document.querySelector('.con')  // 子盒子
        var span = document.querySelector('span')
        // 当我们鼠标经过  sliderbar 就会让con这个盒子滑动到左侧
        // 当我们鼠标离开  sliderbar 就会让con这个盒子滑动到右侧
        sliderbar.addEventListener('mouseenter',function() {
            // animate(obj,target,callback)
            var target = con.offsetWidth - sliderbar.offsetWidth
            animate(con,-target,function() {
                // 当我们动画执行完毕，就把 ← 改为 →
                span.innerHTML = '→'
            })
            
        })
        sliderbar.addEventListener('mouseleave',function() {
            // animate(obj,target,callback)
            // var target = sliderbar.offsetWidth
            animate(con,0,function() {
                // 当我们动画执行完毕，就把 箭头改回去
                span.innerHTML = '←'
            })
        })
    </script>
</body>
</html>